package com.situ.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.situ.springmvc.entity.Student;

@Controller
// 请求映射，怎么样找到这些请求的路径 /student/insert.action
@RequestMapping(value = "/student")
public class StudentController {

	@RequestMapping(value = "/insert1")
	public void insert1(String name, Integer age, String gender) {
		System.out.println("StudentController.insert()");
		System.out.println("name: " + name);
		System.out.println("age: " + age);
		System.out.println("gender: " + gender);
	}
	
	@RequestMapping(value = "/insert")
	public ModelAndView insert(Student student) {
		System.out.println("StudentController.insert()");
		System.out.println(student);
		
		// Model：数据     View：界面
		ModelAndView modelAndView = new ModelAndView();
		// request.setAttribute("student", student);
		modelAndView.addObject("student", student);
		// request.getRequestDispatcher("/student_info.jsp").forward(request,response);
		modelAndView.setViewName("/student_info.jsp");
		return modelAndView;
	}
}

